//导入Nest
import { Module } from '@nestjs/common';
//导入应用主控制器，控制器一般用来定义路径，提供给前端进行ajax调用
import { AppController } from './app.controller';

//导入主服务，主要是用来对数据库中的数据进行操作
import { AppService } from './app.service';
//导入mongoose
import { MongooseModule } from '@nestjs/mongoose';

// 导入Banner模块的控制器
import { BannerController } from './controllers/banner/banner.controller';

//导入操作数据库的Services
import { BannerService } from './services/banner/banner.service';
import { NavigationMenuService } from './services/navigation_menu/navigation_menu.service';
import { NavigationMenuController } from './controllers/navigation_menu/navigation_menu.controller';
import { AllNewAndBenfitController } from './controllers/all-new-and-benfit/all-new-and-benfit.controller';
import { RecommendController } from './controllers/recommend/recommend.controller';
import { AllNewAndBenfitService } from './services/all-new-and-benfit/all-new-and-benfit.service';
import { RecommendService } from './services/recommend/recommend.service';
import { CategoryService } from './services/category/category.service';
import { CategoryController } from './controllers/category/category.controller';
import { NewCategoryService } from './services/new-category/new-category.service';
import { NewCategoryController } from './controllers/new-category/new-category.controller';
import { MessageController } from './controllers/message/message.controller';
import { MessageService } from './services/message/message.service';
import { UserService } from './services/user/user.service';
import { UserController } from './controllers/user/user.controller';
import { ProductDetailService } from './services/product-detail/product-detail.service';
import { ProductDetailController } from './controllers/product-detail/product-detail.controller';
import { CartService } from './services/cart/cart.service';
import { CartController } from './controllers/cart/cart.controller';



//导入定义好的BannerSchema
import BannerSchema from './schemas/banner.schema';
import NavigationMenuSchema from './schemas/navigation_menu.schema';
import CategorySchema from './schemas/category.schema'
import NewCategorySchema from './schemas/new_category_schema'
import MessageScheam from './schemas/message.schema'
import UserSchema from './schemas/user.schema';
import ProductDetailSchema from './schemas/product.schema';
import CartSchema from './schemas/cart.schema';
import LogisticsOrderSchema from './schemas/logisticsorder.schema';





import AllNewAndBenfitSchema from './schemas/allNewAndBenfit.schema';
import RecommendSchema from './schemas/recommend.schema';
import { LogisticsorderController } from './controllers/logisticsorder/logisticsorder.controller';
import { LogisticsorderService } from './services/logisticsorder/logisticsorder.service';



//使用Module装饰器装饰模块, 给模块注入相关服务
@Module({

  //可以导入的模块
  imports: [

    //配置mongoose连接到本地的Mongodb数据库，数据名称为vmall
    MongooseModule.forRoot("mongodb://127.0.0.1/vmall"), // 连接到本地的mongodb数据库，新建数据名称为vmall
    //项目中所有功能模块定义的Schema都注入到这里
    MongooseModule.forFeature([
      {
        name: "BannerTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: BannerSchema
      },

      {
        name: "NavigationMenuTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: NavigationMenuSchema
      },

      {
        name: "AllNewAndBenfitTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: AllNewAndBenfitSchema
      },

      {
        name: "RecommendTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: RecommendSchema
      },

      {
        name: "CategoryTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: CategorySchema
      },
      {
        name: "NewCategoryTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: NewCategorySchema
      },
      {
        name: "MessageTable",  //这个也是mongdb中vmall数据库中对应的表名
        schema: MessageScheam
      },

      {
        name: "User",  //这个也是mongdb中vmall数据库中对应的表名
        schema: UserSchema
      },

      {
        name: "ProductDetail",  //这个也是mongdb中vmall数据库中对应的表名
        schema: ProductDetailSchema
      },

      {
        name: "Cart",  //这个也是mongdb中vmall数据库中对应的表名
        schema: CartSchema
      },

      {
        name: "LogisticsOrder",  //这个也是mongdb中vmall数据库中对应的表名
        schema: LogisticsOrderSchema
      },

    ])
  ],

  /**
    项目中使用了哪些功能模块的控制器，项目中通过下面命令创建的控制器都会注入到controllers数组中
    nest g controller controllers/banner
   */
  controllers: [AppController, BannerController, NavigationMenuController, AllNewAndBenfitController, RecommendController, CategoryController, NewCategoryController, MessageController, UserController, ProductDetailController, CartController,LogisticsorderController],

  /**
   * 项目中指定模块使用哪些服务提供者,项目中通过下面命令创建的服务都会注入到cproviders数组中
   * nest g service services/banner
   */
  providers: [AppService, BannerService, NavigationMenuService, AllNewAndBenfitService, RecommendService, CategoryService, NewCategoryService, MessageService, UserService, ProductDetailService, CartService,LogisticsorderService],
})

export class AppModule { }
